﻿// ***********************************************************************
// Assembly         : INNOVACALL.Framework.Common
// Author           : LJO+01 (Laurent Jordi)
// Created          : 06-05-2013
// Last Modified By : LJO+01 (Laurent Jordi)
// Last Modified On : 06-05-2013
// ***********************************************************************
// <copyright file="InnovacallExceptionExtensions.cs" company="Copyright © Innovacall 2011">
//     Copyright (c) Copyright © Innovacall 2011. All rights reserved.
// </copyright>
// <summary></summary>
// ***********************************************************************
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace INNOVACALL.Framework.Common.InnovacallExceptions
{
    /// <summary>
    /// Class InnovacallExceptionExtensions
    /// </summary>
    public static class InnovacallExceptionExtensions
    {
        /// <summary>
        /// Gets the full exception.
        /// </summary>
        /// <param name="ex">The ex.</param>
        /// <returns>System.String.</returns>
        public static string GetFullException(this Exception ex)
        {
            string toReturn = ex.LayoutException();
            if (ex.InnerException == null) return toReturn;
            return string.Format("{0}\n-:--:--:--:--:--:--:-\n{1}", toReturn, ex.InnerException.GetFullException());
        }
        /// <summary>
        /// Layouts the exception.
        /// </summary>
        /// <param name="ex">The ex.</param>
        /// <returns>System.String.</returns>
        public static string LayoutException(this Exception ex)
        {
            return string.Format("{0}{1}\n{2}", ex.Message, (ex.InnerException != null ? "\n" + ex.InnerException.Message : ""), ex.StackTrace);
        }
    }
}
